#include <iostream>
using namespace std;
const int N = 1e3 + 7;
int n,m,q;
int a[N][N];
int sum[N][N];
int main()
{
  // 请在此输入您的代码
  cin >> n >> m >> q;
  for(int i = 1;i <= n;i++)
  {
    for(int j = 1;j <= m;j++)
    {
      cin >> a[i][j];
    }
  }
  for(int i = 1;i <= n;i++)
  {
    for(int j = 1;j <= m;j++)
    {
      sum[i][j] = sum[i-1][j] + sum[i][j-1] + a[i][j];
    }
  }

  while(q--)
  {
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int ans = 0;
    ans = sum[x2][y2] - sum[x1-1][y2-1] - sum[x2-1][y1-1] + sum[x1-1][y1-1];
    cout << ans << endl;
  }
  return 0;
}